package com.yanqu.road.server.cmd.activity.areapk;

import com.yanqu.road.entity.enums.eGamePlayerEventType;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.pb.cross3.activity.AreaWashePkProto;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.command.Command;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.manger.player.GamePlayerMgr;
import com.yanqu.road.server.protocol.Protocol;
import io.netty.channel.ChannelHandlerContext;

@Cmd(code = Protocol.S_AREA_WASHE_PK_DATA_SYNC_FROM_CHANNEL,desc = "S_AREA_WASHE_PK_DATA_SYNC_FROM_CHANNEL")
public class AreaWashePkUserScoreSyncFromChannelCmd implements Command {

    @Override
    public void execute(ChannelHandlerContext ctx, YanQuMessage yanQuMessage) throws Exception {
        AreaWashePkProto.AreaWashePkUserScoreSync scoreSync = AreaWashePkProto.AreaWashePkUserScoreSync.parseFrom(yanQuMessage.getBytes());
        GamePlayer player = GamePlayerMgr.getOnlinePlayer(scoreSync.getUserId());
        if(player != null){
            player.notifyListener(eGamePlayerEventType.WaShePkUserScoreArchive.getValue(), scoreSync.getScore());
        }
    }
}
